package adavance.thread;

/**
 * @author oldliu
 * @since 1.0
 */
public class ThreadPrint extends Thread {
    public ThreadPrint(String name){
        super(name);
    }

    @Override
    public void run() {
        for (int i = 0; i <20 ; i++) {
            System.out.println(super.getName()+" 打印了 "+i);
        }
    }

    public static void main(String[] args) {
        ThreadPrint[]t=new ThreadPrint[4];
        for(int i=1;i<=4;i++){
            t[i-1]=new ThreadPrint("线程"+i);
        }
        for(Thread th:t)
            th.start();

        //最后执行
        //主线程中join其他的执行完
        for(Thread th:t) {
            try {
                th.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        System.out.println("主线程。。。main over");
    }
}
